from django.shortcuts import render
from LLMTourMapGenApp.models import MapExport
from django.utils.safestring import mark_safe
import json


def index(request):
    return render(request, 'index/index.html')


def export_view(request, export_id):
    try:
        export = MapExport.objects.get(pk=export_id)
        # 使用标准JSON序列化并标记安全
        return render(request, 'export_map/export_map.html',
                      {'json_str': mark_safe(json.dumps(export.json_data))})
    except MapExport.DoesNotExist:
        return render(request, '404.html', status=404)
